﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WITM.DAL
{
    public class UserRepository : IUserRepository, IDisposable
    {
        private WhereIsTheMoneyDBEntities context;

        public UserRepository(WhereIsTheMoneyDBEntities dbcontext)
        {
            context = dbcontext;
        }

        #region IUserRepository Members

        public IEnumerable<Users> GetAll()
        {
            return context.Users.ToList();
        }

        public IEnumerable<Users> Find(System.Linq.Expressions.Expression<Func<Users, bool>> where)
        {
            throw new NotImplementedException();
        }

        public Users First(System.Linq.Expressions.Expression<Func<Users, bool>> where)
        {
            return context.Users.FirstOrDefault(where);
        }

        public void Add(Users user)
        {
            context.AddToUsers(user);
        }

        public void Delete(Users user)
        {
            throw new NotImplementedException();
        }

        public void Attach(Users user)
        {
            context.Attach(user);
        }

        #endregion

        #region IDisposable Members

        public void Dispose()
        {
            if (this.context != null)
            {
                this.context.Dispose();
            }
            GC.SuppressFinalize(this);
        }

        #endregion
    }
}
